package com.cmcc.passenger.data

import androidx.lifecycle.MutableLiveData
import com.cmcc.passenger.data.entity.response.*
import com.cmcc.shared.SdkManager

/**
 * Author: jiangxin
 * Date: 2019/11/14
 * Description:
 * 用于存储公用的数据
 */
class PassDataRepository {

    private var tips: MutableLiveData<List<Gratuity>>? = null
    private var tunnels: MutableLiveData<List<Tunnel>>? = null
    private var carCategories: MutableLiveData<List<CarCategory>>? = null
    private var platforms: MutableLiveData<List<Station>>? = null
    private var remarks: MutableLiveData<List<Remark>>? = null

    fun getRemarks(): MutableLiveData<List<Remark>> {
        if (remarks == null) remarks = MutableLiveData()
        return remarks ?: MutableLiveData()
    }

    fun getTips(): MutableLiveData<List<Gratuity>> {
        if (tips == null) tips = MutableLiveData()
        return tips ?: MutableLiveData()
    }

    fun getTunnels(): MutableLiveData<List<Tunnel>> {
        if (tunnels == null) tunnels = MutableLiveData()
        return tunnels ?: MutableLiveData()
    }

    fun getCarCategories(): MutableLiveData<List<CarCategory>> {
        if (carCategories == null) carCategories = MutableLiveData()
        return carCategories ?: MutableLiveData()
    }

    fun getStations(): MutableLiveData<List<Station>> {
        if (platforms == null) platforms = MutableLiveData()

        var any = ""
        when(SdkManager.getLanguage()){
            0->{
                any = "any"
            }
            1->{
                any = "任何"
            }
            2->{
                any = "任何"
            }
        }
        platforms?.value = mutableListOf(
           // Station("0", any),
            Station("0", "1"),
            Station("1", "2"),
            Station("2", "3"),
            Station("3", "4")
        )
        return platforms ?: MutableLiveData()
    }

    companion object {
        @Volatile
        private var instance: PassDataRepository? = null

        fun getInstance(): PassDataRepository {
            return instance ?: synchronized(this) {
                instance ?: PassDataRepository().also { instance = it }
            }
        }
    }
}